%%
%积分
%2.4.1
clear
syms x b a
y = sym(exp(2*x)*sin(3*x));
z = int(y,x);
%
int(sin(x)/x,x);
%2.4.2
y1 = int(cos(b*x),0,a);%符号运算用的都是int函数
y2 = int(1/(x^2+2*x-3),2,inf);
y3 = int(1/sin(x),0,1);
y4 = int(sin(x)/x,0,1);
vpa(y4);
%%
%2.4.3
clear
syms x
y1 = int(sin(x^2)/(x+1),x,0,1);
y1 = vpa(y1);
y2 = quad('sin(x.^2)./(x+1)',0,1);
y3 = quadl('sin(x.^2)./(x+1)',0,1);
t = 0:0.0001:10;
y4 = trapz(sin(x^2)/(x+1),t);
vpa(y4);
%%
%计算广义积分
clear
ff = @(x)(exp(cos(x)-x.^2));
%y1 = int(ff,-100,100)
y2 = quad(ff,-100,100)
y3 = quadl(ff,-100,100)
clear
ff = @(x)(exp(cos(x)-x.^2));
n = 10;
m = 2;
c = 1e-6;
a = inf;
b = quadl(ff,-n,n);
while abs(a-b)>c,a = b;
    n = n*m;
    b = quadl(ff,-n,n);
end
b;
%%
%2.4.5
clear
syms x
ff = @(x)(1./(1+cos(x))./sqrt(x));
y1 = quadl(ff,1e-5,1);
y2 = quad(ff,1e-5,1);
y3 = quad(ff,0,1);
y4 = vpa(int(1./(1+cos(x))./sqrt(x),0,1),16);
%%
%2.4.6
clear
clc
syms x
ff = sym(nthroot(x,3));
y1 = quadl('nthroot(x,3)',-1,1)
y2 = quad('nthroot(x,3)',-1,1)
y3 = vpa(int(nthroot(x,3),x,-1,1),16)





















